<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    //对象的属性分为两类  数据属性和访问器属性
    var obj = {
      _myName: '星星',
      get myName() {
        console.log('获取myName');
        return this._myName
      },
      set myName(val) {
        console.log('给_myName赋值');
        this._myName = val
      }
    }
    console.log(obj.myName);
    obj.myName = '冰儿'
  </script>
</body>

</html>